package com.liming.web.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.liming.domain.BuyCar;
import com.liming.domain.User;
import com.liming.service.impl.BookServiceImpl;
import com.liming.utils.DBUtils;

public class DelItemServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id=request.getParameter("id");
		BuyCar buycar=(BuyCar) request.getSession().getAttribute("buycar");
		BookServiceImpl service=new BookServiceImpl();
		service.delItem( id, buycar);
		User user=(User)request.getSession().getAttribute("user");
		String sql="delete from Pickbooks where U_username=\'"+user.getUsername()+"\' and B_id=\'"+id+"\'";
		System.out.println(sql);
		DBUtils.delete(sql);
		response.sendRedirect(request.getContextPath()+"/servlet/BuyCarfoUI");
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);

	}

}
